import {request} from "./request";
import {utils} from "../common/utils";

//1.获取所有账户信息
export function getAccountsPaging(accountName,phone,enabled,start,end,pageNum,pageSize) {
    return request({
        url: '/sys/account/page-info',
        method: 'get',
        params: {
            accountName,
            phone,
            enabled,
            start,
            end,
            pageNum,
            pageSize
        }
    });
}

//2.删除账户
export function deleteAccount(accountId) {
    return request({
        url: '/sys/account/' + accountId,
        method: 'delete'
    })
}

//3.禁用账号
export function disableAccount(accountId) {
    return request({
        url: '/sys/account/disable/' + accountId,
        method: 'put'
    })
}

//4.解封账号
export function enableAccount(accountId) {
    return request({
        url: '/sys/account/enable/' + accountId,
        method: 'put'
    })
}

//5.新增账号
export function addAccount(account) {
    return request({
        url: '/sys/account',
        method: 'post',
        data: account
    })
}

//6.删除账号
export function deleteAccountBatch(accountIds) {
    let strUrl = utils.joinArrayReqParam(accountIds,'accountIds');
    return request({
        url: '/sys/account/batch/' + strUrl,
        method: 'delete'
    })
}

//7.修改账号
export function updateAccount(account) {
    return request({
        url: '/sys/account',
        method: 'put',
        data:account
    })
}

//8.获取账号角色编号
export function getAcctRoles(accountId) {
    return request({
        url: '/sys/acct-role/role-ids',
        method: 'get',
        params: {
            accountId
        }
    })
}
